var prefix = "/api/grade/teacher/subject/audit";//用于指向RestController中的方法，方便JS调用服务
var myGrid;

//批量删除按钮
function batchRemove() {
    myGrid.batchRemove();
}

//显示增加对话框按钮
function showAddModel() {
    var thNum = GetQueryString("thNum");

    myGrid.showAddModel("thNum="+thNum);
}

//显示更新对话框按钮
function showUpdateModel(id) {
    myGrid.showUpdateModel(id);
}

//导出Excel按钮
function outExcel(value) {
    myGrid.exportExcel(value);
}

//查詢按钮
function searchTable() {
    myGrid.loadTable();
}

function initgrdesgin(){

    var thNum = GetQueryString("thNum");
    $("#srth_num").val(thNum);
    Tms.select2AjaxData("/api/grade/dimgraprj/getAll",
        "#srth_num", "thNum", "gradeName",thNum);
}

$(function () {
    var options = {
        // ctrfix: "/grade/subject/teacher/audit",//当前控制器(用来拉起edit的html，即在点击“操作”时通过此处的URL+edit来指向对应的edit的HTML文件)
        recordId: 'id',
        tableId: '#subject_Table',
        AddDlgTitle: '新增',
        updateDlgTitle: '更新',
        recordId:'id',
        sort: 'id',
        direct: 'desc',
        deleteURL: function (id) {
            return prefix + "/batchRemove";
        },
        listURL: function () {
            return prefix + "/getByPage"+ "?thNum=2023";
        },
        outExcel:function(){
            return prefix + "/exportExcel";
        },

        columns: [
            {
                checkbox: true
            },
            {
                field: 'id',
                title: '序号',
            },
            {
                field: 'subjectName',
                title: '课题',
            },
            {
                field: 'subjectType',
                title: '课程类型',
            },
            {
                field: 'subjectFrom',
                title: '课题来源',
            },
            {
                field: 'selectType',
                title: '选题方式',
            },
            {
                field: 'stateName',
                title: '审核状态',
            }
            // {
            //     data : null,
            //     title: '操作',
            //     width: '50px',
            //     formatter: function (data,  row, meta) {
            //         var operators = '<a type="button"  href="#" class="btn btn-mint btn-xs btn-icon" onclick=showUpdateModel(' + row.id + ',"' + options.updateDlgTitle + '") title="' + options.updateDlgTitle + '"><i class="demo-psi-pen-5 icon-lg"></i></a>';
            //         return operators;
            //     }
            // }
        ]
    }

    if (s_edit_h == '') {
        options.editable = true;
    } else {
        options.editable = false;
    }

    myGrid = new gridViewModel(options);
    setTimeout(function (){
        myGrid.init();
    },1000)
    initgrdesgin();

})